﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PipeLine : MonoBehaviour
{
    public float Speed;
    public float MInRange;
    public float MaxRanger;
    // Start is called before the first frame update
    void Start()
    {
        Init();

       // Destroy(gameObject, 5f);
    }
    public  void Init()
    {
        float y = Random.Range(MInRange, MaxRanger);
        this.transform.localPosition = new Vector3(0, y, 0);
    }


    float t = 0;
    // Update is called once per frame
    void Update()
    {
        transform.position += new Vector3(-Speed, 0, 0)*Time.deltaTime;

        t += Time.deltaTime;
        if (t>6f)
        {
            t = 0;
            Init();
        }
    }
}
